from abc import ABC, abstractmethod
from typing import Optional


class Player(ABC):
    user = None

    username = None

    def __init__(self):
        pass

    @abstractmethod
    def step(self, board, pos, code, down_pos) -> (int, int):
        """
        下棋
        :param code: 非0表示落子有错误
        :param down_pos:  已落子位置 列表[(x,y)]
        :param board: 当前棋盘
        :param pos: 对手最后落点位置 例子: (x,y)
        :return: 你最后落点位置 例子：(x,y)
        """
        pass

    def get_type(self):
        return self.user

    def get_name(self):
        return self.username

    def set_playinfo(self, user, username):
        self.user = user
        self.username = username